package com.itwk.gulimall.ware.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itwk.common.utils.PageUtils;
import com.itwk.common.utils.Query;
import com.itwk.gulimall.ware.dao.WmsWareInfoDao;
import com.itwk.gulimall.ware.entity.WmsWareInfoEntity;
import com.itwk.gulimall.ware.service.WmsWareInfoService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("wmsWareInfoService")
public class WmsWareInfoServiceImpl extends ServiceImpl<WmsWareInfoDao, WmsWareInfoEntity> implements WmsWareInfoService {

//仓库列表
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //增加仓库检索条件
       String key = (String) params.get("key");
        QueryWrapper<WmsWareInfoEntity> queryWrapper = new QueryWrapper<>();

        if(!StringUtils.isEmpty(key)){
            queryWrapper.eq("id", key).or().like("name", key).or().like("address", key).or().eq("areacode", key);
        }

        IPage<WmsWareInfoEntity> page = this.page(
                new Query<WmsWareInfoEntity>().getPage(params),
                queryWrapper

        );

        return new PageUtils(page);
    }

}